import 'dart:async';
import 'package:get/get.dart';
import 'package:ball_lion/routes/routes.dart';
import 'package:ball_lion/utils/toast_utils.dart';

class AttachDetector {
  static Timer? _timer;

  static List<String> warnRoutes = [
    Routes.myEditInfo,
    Routes.expertApply,
    Routes.accountVerify,
    Routes.login
  ];

  static void warn() {
    if (!warnRoutes.any((element) => Get.currentRoute.contains(element)))
      return;
    int i = 3;
    _timer = Timer.periodic(const Duration(seconds: 5), (timer) {
      i--;
      if (i == 0) {
        Toast.text("当前页面脱离焦点时间长，请注意信息安全");
        _timer?.cancel();
      }
    });
  }

  static void cancelWarn() {
    _timer?.cancel();
  }

  static Future checkSimulator() async {
    // AndroidDeviceInfo androidInfo = await DeviceInfoPlugin().androidInfo;
    // if(!androidInfo.isPhysicalDevice || androidInfo.systemFeatures.every((element) => element.contains("android"))) {
    //   Toast.text("本应用不支持在模拟器中运行");
    //   SystemNavigator.pop();
    // }else{
    //
    // }
  }

  Map<String, List<String>> brand = {
    "oppo": ["oppo", "op", "oplus"]
  };
}
